package com.one.common.common.user.preserter;

import android.content.Context;

import com.one.common.config.CPersisData;
import com.one.common.config.RouterPath;
import com.one.common.manager.ActivityPageManager;
import com.one.common.manager.RouterManager;
import com.one.common.model.http.callback.ObserverOnResultListener;
import com.one.common.presenter.BaseApiPresenter;
import com.one.common.view.base.BaseActivity;
import com.one.common.view.base.IView;
import com.one.common.common.user.modle.UserInfoModel;

/**
 * creator: zhulunjun
 * time:    2018/8/14
 * describe:
 */
public class SettingPresenter extends BaseApiPresenter<IView, UserInfoModel> {

    public SettingPresenter(IView mView, Context mContext) {
        super(mView, mContext, new UserInfoModel((BaseActivity) mContext));
    }

    /**
     * 退出登录
     */
    public void logout(){
        mModel.logout(new ObserverOnResultListener<Object>() {
            @Override
            public void onResult(Object s) {
                if(mView != null){
                    CPersisData.setIsLogin(false);
                    ActivityPageManager.getAppManager().finishAllActivity();
                    RouterManager.getInstance().go(RouterPath.LOGIN_PAGE);
                }
            }
        });
    }
}
